<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="template.xhtml">
	<ui:define name="content">
	
		<f:metadata>  
		    <f:viewParam name="hotelId" value="#{hotelAvailabilityBean.hotelId}" />  
		</f:metadata>
		
		<h2>Gestione Disponibilità hotel "<h:outputText value="#{hotelAvailabilityBean.hotel.name}" />":</h2>

		<p>
			Vuoi inserire una nuova disponibilità? <p:button outcome="newHotelAvailability" value="Crea nuovo elemento" >
			<f:param name="hotelId" value="#{hotelAvailabilityBean.hotelId}" />
			</p:button>
		</p> 
		
		<h:form>
		<p:dataTable var="el" value="#{hotelAvailabilityBean.allHotelAvailabilities}"   
	           emptyMessage="Nessun elemento corrisponde ai criteri di ricerca.">  
	           
           <p:column  
               headerText="Stanza"
               filterMatchMode="contains">  
           	<h:outputText value="#{el.room.name}" />  
	       </p:column> 
	 
	       <p:column    
	               headerText="Da"
	               filterMatchMode="contains">  
	           <h:outputText value="#{el.fromDate}"><f:convertDateTime pattern="dd.MM.yyyy" /></h:outputText> 
	       </p:column>  
	       
	       <p:column   
	               headerText="A"
	               filterMatchMode="contains">  
	           <h:outputText value="#{el.toDate}"><f:convertDateTime pattern="dd.MM.yyyy" /></h:outputText>
	       </p:column> 
	       
	       <p:column    
	               headerText="Posti disponibili"
	               filterMatchMode="contains">  
	           <h:outputText value="#{el.remaining}"/>  
	       </p:column>  
	       
	       <p:column    
	               headerText="Prezzo"
	               filterMatchMode="contains">  
	           <h:outputText value="#{el.price}" />  
	       </p:column>  
	 
	       <p:column>  
	           <center>
		           <p:button outcome="editHotelAvailability" value="Modifica">  
						<f:param name="hotelId" value="#{hotelAvailabilityBean.hotelId}" />  
						<f:param name="elementId" value="#{el.id}" />
				   </p:button>
				   <p:commandButton action="#{hotelAvailabilityBean.deleteHotelAvailability(el.id)}" value="Elimina" />
			   </center>
	       </p:column>  
	   	</p:dataTable>
	 	</h:form>
	   	<br/>
	   	<p:button outcome="manageHotels" value="Torna agli hotel"/>  
	
	
	<p:messages showDetail="true" autoUpdate="true" closable="true" />
		
	</ui:define>
</ui:composition>
</html>